package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode

import java.util.Random;

public class EntityZombieKnight extends EntityMobs {

    public EntityZombieKnight(World world) {
        super(world);
        swingArm = false;
        swingTick = 0;
        texture = "/mob/zombieknight.png";
        moveSpeed = 0.5F;
        attackStrength = 15;
        health = 95;
    }

    public void onLivingUpdate() {
        if(worldObj.isDaytime()) {
            float f = getEntityBrightness(1.0F);

            if(f > 0.5F && worldObj.canBlockSeeTheSky(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)) && rand.nextFloat() * 30F < (f - 0.4F) * 2.0F) {
                fire = 300;
            }
        }

        if(!mod_AIManager.KnightB.get()) {
            setEntityDead();
        }

        if(swingArm) {
            swingTick++;

            if(swingTick == 8) {
                swingTick = 0;
                swingArm = false;
            }
        } else {
            swingTick = 0;
        }

        swingProgress = (float)swingTick / 8F;
        super.onLivingUpdate();
    }

    protected void attackEntity(Entity entity, float f) {
        if((double)f < 2.5D && entity.boundingBox.maxY > boundingBox.minY && entity.boundingBox.minY < boundingBox.maxY) {
            swingArm = true;
            attackTime = 20;
            entity.attackEntityFrom(this, attackStrength);
        }
    }

    protected String getLivingSound() {
        return "mob.zombie";
    }

    protected String getHurtSound() {
        return "mob.zombiehurt";
    }

    protected String getDeathSound() {
        return "mob.zombiedeath";
    }

    protected int getDropItemId() {
        return Item.diamond.shiftedIndex;
    }

    public ItemStack getHeldItem() {
        return new ItemStack(Item.swordSteel, 1);
    }

    public boolean getCanSpawnHere() {
        if(!mod_AIManager.EnableNMModeB.get()) {
            return false;
        }

        if(rand.nextInt(25) == 0) {
            int i = MathHelper.floor_double(posX);
            int j = MathHelper.floor_double(boundingBox.minY);
            int k = MathHelper.floor_double(posZ);

            if(worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > rand.nextInt(32)) {
                return false;
            } else {
                int l = worldObj.getBlockLightValue(i, j, k);
                return l <= rand.nextInt(8) && super.getCanSpawnHere();
            }
        } else {
            return false;
        }
    }

    public boolean swingArm;
    public int swingTick;
}
